<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        let p1 = new Promise((resolve, reject) => {
            let time = Math.random() * 4000 + 1000;
            setTimeout(() => {
                console.log('p1完成');
                resolve();
            }, time)
        });
        let p2 = new Promise((resolve, reject) => {
            let time = Math.random() * 4000 + 1000;
            setTimeout(() => {
                console.log('p2完成');
                resolve();
            }, time)
        });
        let p = Promise.all([p1, p2]);
        p.then(() => {
                console.log('全部执行完毕');
            })
            ///p1和p2全部执行完毕后， 才会执行p.then方法里的操作
    </script>
</head>

<body>

</body>

</html>